<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui"        
                template="../../template/tagedu.xhtml">

    <ui:define name="title">
        <title><h:outputText value="TAG - Editar Plano"/></title>
        <link rel="Stylesheet" type="text/css" href="../../resources/css/main.css"></link>
        <link rel="Stylesheet" type="text/css" href="../../resources/css/plans.css"></link>
        <f:metadata>
            <f:viewParam name="plan" value="#{editPlan.planID}"/>
        </f:metadata>
    </ui:define>

    <ui:define name="content">
        <h:outputText styleClass="planName" value="Edição de Planos"/>
        <f:event type="preRenderComponent" listener="#{editPlan.init()}"/>

        <div id="bodyPlans">
            <h:form styleClass="planOpt">
                <table width="950" border="0" cellpadding="0" cellspacing="0">
                    <tr>
                        <td valign="top" style="">
                            <h:outputLabel styleClass="planOptLabel" for="yearsList" value="Ano: "/>
                            <h:selectOneMenu id="yearsList" styleClass="planOptSOM" value="#{editPlan.plan.planYear}">
                                <f:selectItems value="#{editPlan.yearList}"/>
                            </h:selectOneMenu>
                        </td>
                        <td valign="top" style="">
                            <h:outputLabel styleClass="planOptLabel" for="intervalList" value="Período: "/>
                            <h:selectOneMenu id="intervalList" styleClass="planOptSOM" value="#{editPlan.seasonID}">
                                <f:selectItems value="#{editPlan.seasonList}"/>
                            </h:selectOneMenu>
                        </td>
                        <td valign="top" style="">
                            
                                <h:outputLabel styleClass="planOptLabel" for="discipline" value="Disciplina: "/>
                                <h:selectOneMenu id="disciplineMenu" styleClass="planOptSOM" value="#{editPlan.disciplineID}">
                                    <f:selectItems value="#{editPlan.disciplineList}"/>
                                </h:selectOneMenu>
                     
                        </td>                        
                        <td valign="top" style="">
                            <h:commandButton value="Editar" onclick="infoModal.show()">
                                <f:ajax listener="#{editPlan.edit()}" execute="@form" render="@form :infoForm"/>
                            </h:commandButton>
                        </td>
                    </tr>
                </table>
            </h:form>
        </div>
    </ui:define>

    <ui:define name="modals">
        <p:dialog closable="false" modal="true" header="Atenção" position="center" widgetVar="infoModal" resizable="false">
            <h:form id="infoForm">
                <table width="100%">
                    <tbody>
                        <tr>
                            <td align="center" width="50%">
                                <h:outputText rendered="#{editPlan.success}" value="Edição realizada com sucesso!"/>
                                <br/>
                                <p:commandButton immediate="true" rendered="#{editPlan.success}" value="OK" action="#{editPlan.redirectHome()}"/>
                                <h:outputText rendered="#{!editPlan.success}" value="Por favor, corrija os erros encontrados."/>
                                <br/>
                                <p:commandButton immediate="true" rendered="#{!editPlan.success}" value="OK" onclick="infoModal.hide();"/>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </h:form>
        </p:dialog>
    </ui:define>
</ui:composition>